package xyz.itpath.tools;

import org.apache.commons.lang3.StringUtils;

/**
 * @author zhaom
 */
public class StringUtil extends StringUtils {

    public static final String SIGN_EQUALS = "=";
    public static final String SIGN_PLUS = "+";
    public static final String SIGN_COLON = ":";

    public static String upperFirstLetter(String s){
        if (s.isEmpty()){
            return "";
        }
        return String.valueOf(s.charAt(0)).toUpperCase() + s.substring(1);
    }

    public static String toCamelCase(String s) {
        if (s == null) {
            return null;
        } else {
            s = s.toLowerCase();
            StringBuilder sb = new StringBuilder(s.length());
            boolean upperCase = false;

            for (int i = 0; i < s.length(); ++i) {
                char c = s.charAt(i);
                if (c == '_') {
                    upperCase = true;
                } else if (upperCase) {
                    sb.append(Character.toUpperCase(c));
                    upperCase = false;
                } else {
                    sb.append(c);
                }
            }

            return sb.toString();
        }
    }
}
